"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useFilePreview = exports.checkFile = exports.mindPreview = void 0;
// hooks/useFilePreview.ts
var vue_1 = require("vue");
var index_vue_1 = require("../component/ExcelPreview/index.vue");
var index_vue_2 = require("../component/PDFPreview/index.vue");
var index_vue_3 = require("../component/PicturePreview/index.vue");
var index_vue_4 = require("../component/PPTPreview/index.vue");
var index_vue_5 = require("../component/VideoPreview/index.vue");
var index_vue_6 = require("../component/WordPreview/index.vue");
var index_vue_7 = require("../component/FilesPreview/index.vue");
var index_vue_8 = require("../component/OfficePreview/index.vue");
var index_vue_9 = require("../component/AudioPreview/index.vue");
var index_vue_10 = require("../component/XMindPreview/index.vue");
var imageType = [
    "jpg",
    "png",
    "gif",
    "jpeg",
    "bmp",
    "webp",
    "svg",
    "tiff",
    "tif",
    "jpeg",
    "jfif",
    "pjpeg",
    "pjp"
];
var officeType = ["docx", "xlsx", "pdf", "pptx"];
var outOfficeType = ["doc", "xls", "ppt"];
var videoType = ["mp4", "avi", "wmv", "rmvb", "flv", "mkv"];
var audioType = ["mp3", "wav", "wma", "m4a", "ac3", "dts", "mmf", "m4r", "mp2", "wv", "ogg", "flac", "aac"];
var filesType = [
    "txt",
    "md",
    "log",
    "json",
    "xml",
    "html",
    "css",
    "js",
    "java",
    "c",
    "cpp",
    "h",
    "hpp",
    "py",
    "rb",
    "go",
    "sh",
    "bat",
    "ps1",
    "psm1",
    "ps1xml",
    "psc1",
    "psd1",
    "psm1",
    "ps1xml",
    "psc1",
    "psd1",
    "ps1xml",
    "psc1",
    "ps1xml",
    "psc1",
    "psd1"
];
var xMindType = ['xmind'];
var imagePreview = function (file) {
    console.log('图片预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_3.default))
    };
};
var officePreview = function (file) {
    console.log('office 预览');
    var url = file.url, name = file.name;
    var doc = ['docx'];
    var excel = ['xlsx'];
    var pdf = ['pdf'];
    var ppt = ['pptx'];
    var prefix = url.slice(url.lastIndexOf('.') + 1);
    var result = {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)({}))
    };
    if (doc.includes(prefix))
        result.component = (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_6.default));
    if (excel.includes(prefix))
        result.component = (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_1.default));
    if (pdf.includes(prefix))
        result.component = (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_2.default));
    if (ppt.includes(prefix))
        result.component = (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_4.default));
    return result;
};
var videoPreview = function (file) {
    console.log('视频预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_5.default))
    };
};
var filesPreview = function (file) {
    console.log('文件预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_7.default))
    };
};
var specialOfficePreview = function (file) {
    console.log('office 预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_8.default))
    };
};
var audioPreview = function (file) {
    console.log('audio 预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_9.default))
    };
};
var mindPreview = function (file) {
    console.log('xmind 预览');
    var url = file.url, name = file.name;
    return {
        url: url,
        name: name ? name : '',
        component: (0, vue_1.reactive)((0, vue_1.markRaw)(index_vue_10.default))
    };
};
exports.mindPreview = mindPreview;
var checkFile = function (file) {
    var url = file.url;
    console.log('文件类型', url);
    var fileType = url.slice(url.lastIndexOf('.') + 1).toLowerCase();
    console.log(fileType, '当前文件类型');
    var checkType = function (typeArray) {
        return typeArray.includes(fileType);
    };
    if (checkType(imageType))
        return imagePreview(file);
    if (checkType(officeType))
        return officePreview(file);
    if (checkType(videoType))
        return videoPreview(file);
    if (checkType(filesType))
        return filesPreview(file);
    if (checkType(outOfficeType))
        return specialOfficePreview(file);
    if (checkType(audioType))
        return audioPreview(file);
    if (checkType(xMindType))
        return (0, exports.mindPreview)(file);
};
exports.checkFile = checkFile;
var useFilePreview = function (file) {
    var previewInfo = (0, exports.checkFile)(file);
    return {
        previewInfo: previewInfo
    };
};
exports.useFilePreview = useFilePreview;
